<template>
	<div class="login-scan-container">
		<h2 id="h2login">扫码登录</h2>
		<div class="login-scan-qrcode" ref="qrcodeRef"></div>
	</div>
</template>

<script lang="ts">
import { toRefs, reactive, defineComponent, onMounted, getCurrentInstance } from 'vue';
import QRCode from 'qrcodejs2-fixes';
export default defineComponent({
	name: 'login11',
	setup() {
		const { proxy } = getCurrentInstance() as any;
		const state = reactive({});
		// 初始化生成二维码
		const initQrcode = () => {
			proxy.$refs.qrcodeRef.innerHTML = '';
			new QRCode(proxy.$refs.qrcodeRef, {
				text: `not found interface`,
				width: 260,
				height: 260,
				colorDark: '#000000',
				colorLight: '#ffffff',
			});
		};
		// 页面加载时
		onMounted(() => {
			initQrcode();
		});
		return {
			...toRefs(state),
		};
	},
});
</script>

<style scoped lang="scss">
.login-scan-container {
	text-align: center;
	.login-scan-qrcode {
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -40%);
		margin-top: 15px;
	}
}
#h2login {
	font-size: 25px;
	color: #ffffff;
	margin-top:50px;
}
</style>
